<template>
	<view class="container">
		<view class="margin">
			<view class="text-lg text-black">
				可提现金额:{{userInfo.balance || 0}}元
			</view>
		</view>
		<view class="margin-top solid-bottom">
			<form>
				<view class="cu-form-group">
					<view class="title">姓名</view>
					<input placeholder="请输入真实姓名" name="input" v-model="applyName"></input>
				</view>
				<view class="cu-form-group">
					<view class="title">微信号</view>
					<input placeholder="请输入正确的微信号" name="input" v-model="applyWechat"></input>
				</view>
				<view class="cu-form-group margin-top">
					<view class="title">提现金额</view>
					<input placeholder="请输入提现金额" name="input" type="digit" v-model="amount"></input>
				</view>
			</form>
		</view>
		<view class="padding flex flex-direction">
			<button class="cu-btn bg-red margin-tb-sm lg" @click="apply()">提交</button>
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				applyName:"",
				applyWechat:"",
				amount:0
			}
		},
		methods:{
			navTo:function(url){
				uni.navigateTo({
					url:url
				})
			},
			apply:function(){
				
				if(!this.applyName){
					this.$api.msg("请输入姓名");
					return;
				}
				if(!this.applyWechat){
					this.$api.msg("请输入微信号");
					return;
				}
				if(this.amount <=0 || this.amount>this.userInfo.balance){
					this.$api.msg("请输入正确的金额");
					return;
				}
				var that = this;
				that.$api.req({
					userId:that.userInfo.id,
					userName:that.userInfo.nickName,
					applyName:that.applyName,
					applyWechat:that.applyWechat,
					amount:that.amount
				}, "/memberCashApply/apply").then((res) => {
					console.log(res);
					var d = res.data;
					if(d.success){
						that.$api.msg("申请成功！");
						uni.switchTab({
							url:"../user/user"
						})
					}else{
						that.$api.msg(d.msg);
					}
				})
			}
		}
	}
</script>

<style>
</style>
